#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Mikan CGI開発 サーバ 機能

Mikan Python Web Framework
"""

__author__ = "K.Sonohara"
__status__ = "develop"
__version__ = "0.0.0_b"
__date__    = "2013/03/24"
__license__ = 'LGPL'

# ------------------------------------------------------------
## インポート
# ------------------------------------------------------------
# Python
#import BaseHTTPServer
from CGIHTTPServer import CGIHTTPRequestHandler
import BaseHTTPServer

# Mikan

# ------------------------------------------------------------
## 変数
# ------------------------------------------------------------
hostname = '0.0.0.0'
hostport = 8080

# ------------------------------------------------------------
## 関数
# ------------------------------------------------------------

# ------------------------------------------------------------
## クラス
# ------------------------------------------------------------

# ------------------------------------------------------------
## メイン関数
# ------------------------------------------------------------
if __name__ == '__main__':
	class MyHandler(CGIHTTPRequestHandler):
		cgi_directories=["/cgi-bin"]

		def translate_path(self, path):
			if path.startswith("/cgi-bin"):
				r = path
			elif path == "":
				r = ""
			else:
				r = u"/%s%s" % ("htdocs", path)

			a = CGIHTTPRequestHandler.translate_path(self, r)
			return a

	httpd = BaseHTTPServer.HTTPServer((hostname, hostport), MyHandler)
	httpd.serve_forever()

# ------------------------------------------------------------
